/**
 * Created by no1 on 2014/8/29.
 */
'use strict';
var F = require('../common/function');
var commPost = require('../common/post');
var commUser = require('../common/user');
var commPublic = require('../common/public');
var C = require('../config/index');
//var msgpack=require('msgpack5')();
//var encode  = msgpack.encode;
//var decode  = msgpack.decode;

module.exports = function (app) {
  var self = this;
  var apiPre = C.apiPre;

  /*
   @todo API01 获取短信验证码
   */
  app.get(apiPre + '/:apiVer/verification', function*() {
    this.I = yield F.Init(this, [1, 11, 2, 12]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, this.I.errors.level);
    } else {
      this.jsonp = yield commUser.sendVerification(this);
    }
  });
  /*
   @todo API02 获取短信验证凭证
   */
  app.get(apiPre + '/:apiVer/registerTicket', function*() {
    this.I = yield F.Init(this, [1, 2, 3, 4, 11]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, this.I.errors.level);
    } else {
      this.jsonp = yield commUser.registerTicket(this);
    }
  });

  /*
   @todo API03 注册
   */
  app.post(apiPre + '/:apiVer/register', function* () {
    this.I = yield F.Init(this, [1, 2, 11]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, this.I.errors.level);
    } else {
      this.jsonp = yield commUser.register(this);
    }
  });

  /*
   @todo API04 登录
   */
  app.post(apiPre + '/:apiVer/login', function*() {
    this.I = yield F.Init(this, [1, 2, 11]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, this.I.errors.level);
    } else {
      this.jsonp = yield commUser.login(this);
    }
  });

  /*
   @todo API05 登出
   */
  app.post(apiPre + '/:apiVer/logout', function*() {
    this.I = yield F.Init(this, [1, 11]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, this.I.errors.level);
    } else {
      this.jsonp = yield commUser.logout(this);
    }
  });

  /*
   @todo API06 获取个人资料
   */
  app.get(apiPre + '/:apiVer/userinfo', function*() {
    this.I = yield F.Init(this, [1, 2, 11]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, this.I.errors.level);
    } else {
      this.jsonp = yield commUser.getUserinfo(this);
    }
  });

  /*
   @todo API07 修改个人资料
   */
  app.post(apiPre + '/:apiVer/userinfo', function*() {
    this.I = yield F.Init(this, [1, 11]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, this.I.errors.level);
    } else {
      this.jsonp = yield commUser.setUserinfo(this);
    }
  });

  /*
   @todo API08 获取标签
   */
  app.post(apiPre + '/:apiVer/tags', function*() {
    this.I = yield F.Init(this, [1, 2, 11]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, this.I.errors.level);
    } else {
      this.jsonp = yield commPost.tags(this);
    }
  });

  /*
   @todo API09 添加用户自定义标签(已转到后台api19)
   */


  /*
   @todo API10 修改、重置用户密码
   */
  app.post(apiPre + '/:apiVer/userpassword', function*() {
    this.I = yield F.Init(this, [1, 2, 11, 12, 3]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, this.I.errors.level);
    } else {
      this.jsonp = yield commUser.changePassword(this);
    }
  });

  /*
   @todo API11 发布一个主题帖
   */
  app.post(apiPre + '/:apiVer/thread', function*() {
    this.I = yield F.Init(this, [1, 11]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, this.I.errors.level);
    } else {
      this.jsonp = yield commPost.thread(this);
    }
  });

  /*
   @todo API12 回复一个主题帖
   */
  app.post(apiPre + '/:apiVer/post', function*() {
    this.I = yield F.Init(this, [1, 11]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, this.I.errors.level);
    } else {
      this.jsonp = yield commPost.post(this);
    }
  });

  /*
   @todo	API13 取头像又拍云上传秘钥
   */
  app.post(apiPre + '/:apiVer/upyunImg', function*() {
    this.I = yield F.Init(this, [1, 11]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, this.I.errors.level);
    } else {
      this.jsonp = yield commUser.upyunImg(this);
    }
  });

  /*
   @todo API14 点赞或取消点赞某主题
   */
  app.post(apiPre + '/:apiVer/like', function*() {
    this.I = yield F.Init(this, [1, 2, 3, 11, 12, 13]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, this.I.errors.level);
    } else {
      this.jsonp = yield commPost.like(this);
    }
  });

  /*
   @todo API15 关注或取消关注某人
   */
  app.post(apiPre + '/:apiVer/friend', function*() {
    this.I = yield F.Init(this, [1, 2, 11, 12]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, this.I.errors.level);
    } else {
      this.jsonp = yield commUser.friend(this);
    }
  });

  /*
   @todo API16 收藏或取消收藏某主题
   */
  app.post(apiPre + '/:apiVer/fav', function*() {
    this.I = yield F.Init(this, [1, 2, 11, 12]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, this.I.errors.level);
    } else {
      this.jsonp = yield commPost.fav(this);
    }
  });

  /*
   @todo API17 订阅或取消订阅某标签
   */
  app.post(apiPre + '/:apiVer/pinTag', function*() {
    this.I = yield F.Init(this, [1, 2, 3, 11, 12, 13]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, this.I.errors.level);
    } else {
      this.jsonp = yield commUser.pinTag(this);
    }
  });

  /*
   @todo API18 主题列表
   */
  app.get(apiPre + '/:apiVer/postlist', function*() {
    this.I = yield F.Init(this, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, this.I.errors.level);
    } else {
      this.jsonp = yield commPost.getPostList(this);
    }
    yield F.robotLike();
  });

  /*
   @todo API19 主题帖信息(已转到api18 act=8)
   */
  app.get(apiPre + '/:apiVer/thread', function*() {
    this.I = yield F.Init(this, [1, 11]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, this.I.errors.level);
    } else {
      this.jsonp = yield commPost.getThread(this);
    }
  });

  /*
   @todo API20 回帖列表
   */
  app.get(apiPre + '/:apiVer/post', function*() {
    this.I = yield F.Init(this, [1, 2, 11]);//2包含推荐阅读，热门评论列表
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, this.I.errors.level);
    } else {
      this.jsonp = yield commPost.getPost(this);
      this.jsonp = yield commPost.getPost(this);
    }
  });


  /*
   @todo API21 标签列表
   */
  app.get(apiPre + '/:apiVer/tagsList', function*() {
    this.I = yield F.Init(this, [1, 2, 3, 4, 5, 6, 11, 12]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, this.I.errors.level);
    } else {
      this.jsonp = yield commPost.tagsList(this);
    }
  });


  /*todo API22 动态信息列表
   @
   */
  app.get(apiPre + '/:apiVer/dynamicInfo', function*() {
    this.I = yield F.Init(this, [1, 11]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, this.I.errors.level);
    } else {
      this.jsonp = yield commUser.getDynamicInfo(this);
    }
  });

  /*
   @todo API23 关注及粉丝列表
   */
  app.get(apiPre + '/:apiVer/friend', function*() {
    this.I = yield F.Init(this, [1, 2, 11, 12]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, this.I.errors.level);
    } else {
      this.jsonp = yield commUser.getFriendList(this);
    }
  });

  /*
   @todo API25 友盟device_token捆绑
   */
  app.post(apiPre + '/:apiVer/bindUmeng', function*() {
    this.I = yield F.Init(this, [1]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, this.I.errors.level);
    } else {
      this.jsonp = yield commUser.bindUmeng(this);
    }
  });

  /*
   @todo API26 推送开关设置
   */
  app.post(apiPre + '/:apiVer/settingPush', function*() {
    this.I = yield F.Init(this, [1, 2]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, this.I.errors.level);
    } else {
      this.jsonp = yield commUser.settingPush(this);
    }
  });

  /*
   @todo API27	获取版本升级信息
   */
  app.get(apiPre + '/:apiVer/appUpdate', function*() {
    this.I = yield F.Init(this, [1, 2, 3]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, this.I.errors.level);
    } else {
      this.jsonp = yield commUser.appUpdate(this);
    }
  });

  /*
   @todo API28 主题帖分享后回调统计接口
   */
  app.post(apiPre + '/:apiVer/threadShare', function*() {
    this.I = yield F.Init(this, [1]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, 3); // 不提醒客户数据格式错误
    } else {
      this.jsonp = yield commPost.threadShare(this);
    }
  });

  /*
   @todo API29 贴子投诉
   */
  app.post(apiPre + '/:apiVer/complaintPost', function*() {
    this.I = yield F.Init(this, [1]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, 3); // 不提醒客户数据格式错误
    } else {
      this.jsonp = yield commPost.complaintPost(this);
    }
  });

  /*
   @todo API30 刷新又拍云图片
   */
  app.post(apiPre + '/:apiVer/upyunPurge', function*() {
    this.I = yield F.Init(this, [1]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, 3); // 不提醒客户数据格式错误
    } else {
      this.jsonp = yield commPost.upyunPurge(this);
    }
  });
  /**
   * @todo API31 帖子图片上传成功后的Callback
   */
  app.post(apiPre + '/:apiVer/imgCallback', function*() {
    this.I = yield F.Init(this, [1]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, 3); // 不提醒客户数据格式错误
    } else {
      this.jsonp = yield commPost.imgCallback(this);
    }
  });

  /**
   * @todo API32 取轮播
   */
  app.get(apiPre + '/:apiVer/getSlider', function*() {
    this.I = yield F.Init(this, [1]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, 3); // 不提醒客户数据格式错误
    } else {
      this.jsonp = yield commPost.getSlider(this);
    }
  });

  /**
   * @todo API33 获取用户列表（暂时不用）
   */
  app.get(apiPre + '/:apiVer/usersList', function*() {
    this.I = yield F.Init(this, [1]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, 3); // 不提醒客户数据格式错误
    } else {
      this.jsonp = yield commUser.usersList(this);
    }
  });
  /**
   * @todo API34 社会化登录
   */
  app.post(apiPre + '/:apiVer/doOauthLogin', function*() {
    this.I = yield F.Init(this, [1]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, 3); // 不提醒客户数据格式错误
    } else {
      this.jsonp = yield commUser.doOauthLogin(this);
    }
  });

  /**
   * @todo API35 头像上传成功后的Callback
   */
  app.post(apiPre + '/:apiVer/faceCallback', function*() {
    this.I = yield F.Init(this, [1]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, 3); // 不提醒客户数据格式错误
    } else {
      this.jsonp = yield commUser.faceCallback(this);
    }
  });

  /**
   * @todo API36 意见反馈
   */
  app.post(apiPre + '/:apiVer/suggest', function*() {
    this.I = yield F.Init(this, [1]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, 3); // 不提醒客户数据格式错误
    } else {
      this.jsonp = yield commUser.suggest(this);
    }
  });

  /**
   * @todo API37 删除主题帖、回帖
   */
  app.post(apiPre + '/:apiVer/delPost', function*() {
    this.I = yield F.Init(this, [1, 2]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, 3); // 不提醒客户数据格式错误
    } else {
      this.jsonp = yield commPost.delPost(this);
    }
  });

  /*
   @todo API38.	社会化分享后统计接口
   */
  app.post(apiPre + '/:apiVer/shareCallback', function*() {
    this.I = yield F.Init(this, [1]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, 3); // 不提醒客户数据格式错误
    } else {
      this.jsonp = yield commPost.shareCallback(this);
    }
  });

  /*
   @todo API39.	获取用户
   */
  app.post(apiPre + '/:apiVer/getUsers', function*() {
    this.I = yield F.Init(this, [1, 2]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, 3); // 不提醒客户数据格式错误
    } else {
      this.jsonp = yield commUser.getUsers(this);
    }
  });

  /*
   @todo API40.	省市区街道列表
   */
  app.get(apiPre + '/:apiVer/cityList', function*() {
    this.I = yield F.Init(this, [1, 2]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, 3); // 不提醒客户数据格式错误
    } else {
      this.jsonp = yield commPost.cityList(this);
    }
  });

  /*
   @todo API41.	动态、通知、消息未读数目
   */
  app.get(apiPre + '/:apiVer/getUnread', function*() {
    this.I = yield F.Init(this, [1]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, 3); // 不提醒客户数据格式错误
    } else {
      this.jsonp = yield commUser.getUnread(this);
    }
  });

  /*
   @todo API42.	签到
   */
  app.post(apiPre + '/:apiVer/signin', function*() {
    this.I = yield F.Init(this, [1, 2]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, 3); // 不提醒客户数据格式错误
    } else {
      this.jsonp = yield commUser.signin(this);
    }
  });

  /*
   @todo API43.	更新地理位置
   */
  app.post(apiPre + '/:apiVer/updateGeo', function*() {
    this.I = yield F.Init(this, [1]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, 3); // 不提醒客户数据格式错误
    } else {
      this.jsonp = yield commUser.updateGeo(this);
    }
  });

  /*
   @todo API44.	获取用户今日任务
   */
  app.get(apiPre + '/:apiVer/getTask', function*() {
    this.I = yield F.Init(this, [1]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, 3); // 不提醒客户数据格式错误
    } else {
      this.jsonp = yield commUser.getTask(this);
    }
  });

  /*
   @todo API45.	获取达人分类列表
   */
  app.get(apiPre + '/:apiVer/getTalentList', function*() {
    this.I = yield F.Init(this, [1]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, 3); // 不提醒客户数据格式错误
    } else {
      this.jsonp = yield commUser.getTalentList(this);
    }
  });

  /*
   @todo API46.	申请达人
   */
  app.post(apiPre + '/:apiVer/askForTalent', function*() {
    this.I = yield F.Init(this, [1]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, 3); // 不提醒客户数据格式错误
    } else {
      this.jsonp = yield commUser.askForTalent(this);
    }
  });

  /*
   @todo API47.	达人排行榜
   */
  app.get(apiPre + '/:apiVer/talentRanking', function*() {
    this.I = yield F.Init(this, [1]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, 3); // 不提醒客户数据格式错误
    } else {
      this.jsonp = yield commUser.talentRanking(this);
    }
  });

  /*
   @todo API48.	用户收货地址
   */
  app.post(apiPre + '/:apiVer/userAddress', function*() {
    this.I = yield F.Init(this, [1, 2, 3, 4, 5]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, 3); // 不提醒客户数据格式错误
    } else {
      this.jsonp = yield commUser.address(this);
    }
  });

  /*
   @todo API49.	活动信息查询
   */
  app.post(apiPre + '/:apiVer/activityInfo', function*() {
    this.I = yield F.Init(this, [1]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, 3); // 不提醒客户数据格式错误
    } else {
      this.jsonp = yield commUser.UseractivityState(this);
    }
  });

  /*
   @todo API50. 地图显示
   */
  app.post(apiPre + '/:apiVer/mapInfo', function*() {
    this.I = yield F.Init(this, [1]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, 3); // 不提醒客户数据格式错误
    } else {
      this.jsonp = yield commPublic.mapInfo(this);
    }
  });


  /*
   @todo API51.	活动领兑换码
   */
  app.get(apiPre + '/:apiVer/activityRedeemCode', function*() {
    this.I = yield F.Init(this, [1, 2]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, 3); // 不提醒客户数据格式错误
    } else {
      this.jsonp = yield commUser.activityRedeemCode(this);
    }
  });

  /*
   @todo API49b.	活动信息查询
   */
  app.get(apiPre + '/:apiVer/activityState', function*() {
    this.I = yield F.Init(this, [1]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, 3); // 不提醒客户数据格式错误
    } else {
      this.jsonp = yield commUser.userActivityState(this);
    }
  });

  /*
   @todo API52.	女性生理周期管理
   */
  app.post(apiPre + '/:apiVer/menstruationInfo', function*() {
    this.I = yield F.Init(this, [1, 2, 3]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, 3); // 不提醒客户数据格式错误
    } else {
      this.jsonp = yield commUser.menstruationInfo(this);
    }
  });
  /*
   @todo API53.	获取用户关注的帖子类别
   */
  app.get(apiPre + '/:apiVer/userCategoryInfo', function*() {
    this.I = yield F.Init(this, [1, 2, 3, 4]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, 3); // 不提醒客户数据格式错误
    } else {
      this.jsonp = yield commUser.userCategoryInfo(this);
    }
  });
  /*
   *todo API54  瓷肌二维码鉴别
   */
  app.get(apiPre + '/:apiVer/ck2dcode', function*() {
    this.I = yield F.Init(this, [1]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, 3);
    } else {
      this.jsonp = yield commUser.ck2dcode(this);
    }
  });

  /*
   @todo API55 获取用户发布的美容贴列表
   */
  app.post(apiPre + '/:apiVer/getUserDailyCover', function*() {
    this.I = yield F.Init(this, [1, 2, 3, 4]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, 3);
    } else {
      this.jsonp = yield commUser.userDailyOperation(this);
    }
  });

  /*
   *todo API56  根据发帖主贴内容自动获取分类
   */
  app.post(apiPre + '/:apiVer/getautoCate', function*() {
    this.I = yield F.Init(this, [1]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, 3);
    } else {
      this.jsonp = yield commPost.getautoCate(this);
    }
  });

  /*
   *todo API57 记录帖子图片、视频，头像点击来源
   */
  app.post(apiPre + '/:apiVer/countMediaViews', function*() {
    this.I = yield F.Init(this, [1, 2, 3]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, 3);
    } else {
      this.jsonp = yield commPost.countMeidaViews(this);
    }
  });

  /*
   @todo API58 绑定或解绑第三方媒体账号
   */
  app.post(apiPre + '/:apiVer/bindUserAccount', function*() {
    this.I = yield F.Init(this, [1, 2, 3]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, 3);
    } else {
      this.jsonp = yield commUser.bindUserAccount(this);
    }
  });


  /**
   * @todo API59 获取o2o分类列表
   */
  app.post(apiPre + '/:apiVer/geto2oCate', function*() {
    this.I = yield F.Init(this, [1]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, 3);
    } else {
      this.jsonp = yield commPost.geto2oCate();
    }
  });

  /*
   * @todo API60 随机抽奖API
   */
  app.post(apiPre + '/:apiVer/randomGit', function*() {
    this.I = yield F.Init(this, [1, 2, 3, 4, 5, 6]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, 3);
    } else {
      this.jsonp = yield commUser.randomGit(this);
    }
  });

  /*
   * @todo API61 获取瓷肌百科页面
   */
  app.post(apiPre + '/:apiVer/getCiJiWiki', function*() {
    this.I = yield F.Init(this, [1]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, 3);
    } else {
      this.jsonp = yield commPost.getCiJiWiki(this);
    }
  });

  /*
   * @todo API62 Q商城h5获取用户信息
   */
  app.post(apiPre + '/:apiVer/getUserInfoH5', function*() {
    this.I = yield F.Init(this, [1, 2]);
    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, 3);
    } else {
      this.jsonp = yield commUser.getUserInfoH5(this);
    }
  })

  /*
   *todo API—Time  根据发帖主贴内容自动获取分类
   */
  app.get(apiPre + '/:apiVer/getTime', function*() {
    this.jsonp = F.returnMsg();
  });


  app.get(apiPre + '/:apiVer/myTest', function*() {
    this.I = yield F.Init(this, [83, 84, 85, 70, 71]);

    if (this.I.errors) {
      this.jsonp = F.returnMsg(400, this.I.errors.msg, 3); // 不提醒客户数据格式错误
    } else {
      if (this.I.act == 83) {//获取附近的标签
        this.jsonp = yield F.poiModel.geoNear([113.317124, 23.129226], {
          maxDistance: 100 / 6371, // 单位弧度
          spherical: true,
          distanceMultiplier: 6371   // 1弧度=6371km
        });
      } else if (this.I.act == 84) {
        yield commUser.tranPoiList(this);
        this.jsonp = {};
      } else if (this.I.act == 85) {//获取附近的人
        this.jsonp = yield F.userModel.geoNear([113.317124, 23.129226], {
          maxDistance: 100 / 6371, // 单位弧度
          spherical: true,
          distanceMultiplier: 6371   // 1弧度=6371km
        });
      } else if (this.I.act == 70) {
        this.jsonp = yield F.getBrondTagid();
      } else if (this.I.act == 71) {//测试用
        var retData = yield F.getSliderNew({title: '发现页专题', stid: 12, more: 1, limit: 4});
        this.jsonp = retData;
      }
    }

    //var aa = yield F.poiModel.find({});
    //this.jsonp = aa;
  });


  /**
   * todo api获取token
   * get /api/v1/token?tokenkey=xxxx
   * 返回的数据中包含3个字段 uid,manager,date
   */
  app.get(apiPre + '/:apiVer/token', function*() {
    this.I = yield F.Init(this, []);
    if (this.I.errors) return this.jsonp = F.returnMsg(400, this.I.errors.msg, 3);
    var token = F.getToken2.call(this);
    this.jsonp = F.returnMsg(200, null, 1, {token: token});
  });

  /**
   * get /api/v1/face/user/upload?act=1&tokenkey=xxxx
   * 获取 upload face 所需要的数据
   */
  app.get(apiPre + '/:apiVer/face/user/upload', function*() {
    this.I = yield F.Init(this, [1]);
    //console.log('foobar1', JSON.stringify(this.I));
    if (this.I.errors) return this.jsonp = F.returnMsg(400, this.I.errors.msg, 3);
    var token = F.getToken2.call(this);
    this.jsonp = F.returnMsg(200, null, 1, {
      token: token,
      url: C.face.upUserFace
    });
  });

  /**
   * get /api/v1/face/user/parts/all
   * 获取 upload face 所需要的数据
   */
  app.get(apiPre + '/:apiVer/face/parts/all', function*() {
    this.I = yield F.Init(this, []);
    if (this.I.errors) return this.jsonp = F.returnMsg(400, this.I.errors.msg, 3);
    var token = F.getToken2.call(this);
    var url = C.face.getAllParts;
    url = url.replace('%token', token);
    var rvalue = yield F.promiseRequest({url: url, method: 'GET'});
    if (!rvalue || rvalue.error) return this.jsonp = F.returnMsg(400, 'system error', 3);
    var rbody = JSON.parse(rvalue.body);
    this.jsonp = F.returnMsg(200, null, 1, rbody.result);
  });

  /**
   * get /api/v1/face/render?act=1&token=xxx
   * {"ufaceid":xx,"partids":xx}
   * 获取 upload face 所需要的数据
   */
  app.post(apiPre + '/:apiVer/face/render', function*() {
    this.I = yield F.Init(this, [1]);
    if (this.I.errors) return this.jsonp = F.returnMsg(400, this.I.errors.msg, 3);
    var ufaceid = this.I.ufaceid;
    var partids = this.I.partids;
    var token = this.I.token || F.getToken2.call(this);
    var url = C.face.renderUrl;
    var rvalue = yield F.promiseRequest({
      url: url,
      method: 'POST',
      json: {
        token: token,
        ufaceid: ufaceid,
        partids: partids
      }
    });
    if (!rvalue || rvalue.error) return this.jsonp = F.returnMsg(400, 'system error', 3);
    this.jsonp = F.returnMsg(200, null, 1, rvalue.body.result);
  });
};

